package com.mida.dms.knw.mapper;

import com.mida.dms.knw.entity.KnwSlot;
import com.mida.dms.knw.entity.vo.KnwSlotPage;
import com.mida.dms.knw.entity.vo.KnwSlotVo;
import org.apache.ibatis.annotations.Param;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public interface KnwSlotMapper extends BaseMapper<KnwSlot> {

    List<KnwSlotVo> findPageByDetail(KnwSlotPage npage);

    List<KnwSlotVo> findSlotPageByDetail(KnwSlotPage npage);

    KnwSlotVo findBySoid(Long soid);

    Long getMaxSlotOrder(Long noumenonSoid);

    boolean updateSlotOrderPlus(@Param("slotOrderStart") Long slotOrderStart, @Param("slotOrderEnd") Long slotOrderEnd, @Param("slotSoid") Long slotSoid, @Param("noumenonSoid") Long noumenonSoid);

    boolean updateSlotOrderLess(@Param("slotOrderStart") Long slotOrderStart, @Param("slotOrderEnd") Long slotOrderEnd, @Param("slotSoid") Long slotSoid, @Param("noumenonSoid") Long noumenonSoid);

    boolean updateStatusBySoid(KnwSlotVo knwSlotVo) throws SQLException;

    boolean stopAllAssociatedSlot(KnwSlotVo knwSlotVo);

    boolean updateByPrimaryKeySelective(KnwSlot knwSlot);

    List<KnwSlot> selectDistinct(KnwSlotVo knwSlotVo);

    List<KnwSlot> selectDistinctWithKnwSlot(KnwSlot knwSlot);

    void updateIsDeleteBySlotSoid(KnwSlot slot);

    boolean adjustSlotOrder(@Param("noumenonSoid") Long noumenonSoid, @Param("slotOrder") Long slotOrder);

    KnwSlot selectSlotOnStatus(Long slotSoid);

    List<KnwSlotVo> selectAllSlotVoByNoumenonSoid(Long noumenonSoid);

    List<KnwSlot> selectAllSlotByNoumenonSoid(Long noumenonSoid);

    Long getSlotOrder(Long slotSoid);

    /**
     * 查询本体对应的slot数量
     * @param noumenonSoid
     * @return
     */
    Integer countSlotByNoumenonSoid(Long noumenonSoid);

    int getCntByDcsSoid(Long dataSourceSoid) throws Exception;

    void updateDetailCoding(@Param("slotSoid") Long slotSoid, @Param("detailCodingSystemSoid") Long detailCodingSystemSoid);

    List<KnwSlotVo> getAllSlotVoByNoumenonSoid(Long noumenonSoid) throws Exception;

    KnwSlotVo findSlotBySlotSoid(Long soid);

    List<KnwSlotVo> findSlots(Map<String, Object> map) throws Exception;
}